package com.qf.dto;

import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;

import java.nio.charset.StandardCharsets;
import java.util.UUID;

public class Md5 {

    public static String RandomSalt(){

        return StringUtils.replace(UUID.randomUUID().toString(), "-", "").substring(0, 9);
    }

    public static String md5AndSalt(String salt,String password){

        String valueOf = String.valueOf((password + salt).hashCode());
        String newpassword = DigestUtils.md5DigestAsHex(valueOf.getBytes(StandardCharsets.UTF_8));
        return newpassword;

    }
}
